package part01_七大原则.p02_接口隔离原则;

/**
 * @ClassName: Segregation02
 * @Author: AllenSun
 * @Date: 2019/12/2 22:25
 */
//把接口Interface01 拆分为独立的几个接口
//类A和类C分别与他们自己需要的接口建立依赖关系，也就是采用接口隔离原则
public class Segregation02 {
    public static void main(String[] args) {

    }
}

//接口01
interface Interface_01{
    void operation01();
}

//接口02
interface Interface_02{
    void operation02();
    void operation03();
}

//接口02
interface Interface_03{
    void operation04();
    void operation05();
}

class BB implements Interface_01,Interface_02{

    @Override
    public void operation01() {
        System.out.println("B 实现了operation01");
    }

    @Override
    public void operation02() {
        System.out.println("B 实现了operation02");
    }

    @Override
    public void operation03() {
        System.out.println("B 实现了operation03");
    }
}

class DD implements Interface_01,Interface_03{
    @Override
    public void operation01() {
        System.out.println("D 实现了operation01");
    }

    @Override
    public void operation04() {
        System.out.println("D 实现了operation04");
    }

    @Override
    public void operation05() {
        System.out.println("D 实现了operation05");
    }
}

class AA{
    public void depend01(Interface_01 i){
        i.operation01();
    }

    public void depend02(Interface_02 i){
        i.operation02();
    }

    public void depend03(Interface_02 i){
        i.operation03();
    }
}

class CC{
    public void depend01(Interface_01 i){
        i.operation01();
    }
    public void depend04(Interface_03 i){
        i.operation04();
    }
    public void depend05(Interface_03 i){
        i.operation05();
    }
}